#include "gl_parser.h"

#include "bd_gps.h"
#include "stdio.h"
#include "ble.h"

#include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h"

struct BD_GPS_STRUCT bd_gps_car_s;
struct CAR_VALUE_STRUCT car_value_s;

void parse_status_frame(PARSE_STRUCT *parser_s)
{
    uint8_t error_code;
    FRAME_STRUCT frame_s;
    frame_s.Version = PROTOCOL_VERSION;
    frame_s.FrameDataLen = 0;
    frame_s.frame_data = NULL;
    frame_s.send_frame_fun = parser_s->frame_s.send_frame_fun;
    frame_s.MasterCmd = MASTER_CMD_STATUS;

    if(parser_s->frame_s.MasterCmd != MASTER_CMD_STATUS)
    {
        frame_s.SlaveCmd = SLAVE_CMD_STATUS_ERROR;
    }else{
        switch(parser_s->frame_s.SlaveCmd)
        {
            case SLAVE_CMD_STATUS_GPS:
            
            //printf("recv status\r\n");
            
            memcpy(&bd_gps_car_s,parser_s->frame_s.frame_data,sizeof(struct BD_GPS_STRUCT));
            
            frame_s.SlaveCmd = SLAVE_CMD_STATUS_GPS_SUCCESS;
            frame_s.FrameDataLen = 0;
            frame_s.frame_data = NULL;
            break;   
            case SLAVE_CMD_CAR_VALUE:     

            memcpy(&car_value_s,parser_s->frame_s.frame_data,sizeof(struct CAR_VALUE_STRUCT));
            
            break; 
            default:
            frame_s.SlaveCmd = SLAVE_CMD_STATUS_ERROR;
            break;
        }
    }

    //creat_send_cmd(&frame_s);
}

